<?php

/**
 * 后台首页
 */
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
use Common\Model\RoleModel;

class IndexController extends AdminbaseController {
	
	function _initialize() {
	    empty($_GET['upw'])?"":session("__SP_UPW__",$_GET['upw']);//设置后台登录加密码
		parent::_initialize();
		$this->initMenu();
	}
	
    /**
     * 后台框架首页
     */
    public function index() {
    	if (C('LANG_SWITCH_ON',null,false)){
    		$this->load_menu_lang();
    	}
//        return print_r(D("Common/SysMenu")->menu_json());
        $list=D("Common/SysMenu")->menu_json();
        $res=D("vrnews1.area_admin")->where(array('admin_id' => $_SESSION['ADMIN_ID']))->find();
        if(!$res||$_SESSION['ADMIN_ID']==1){
            foreach ($list as $key => $value) {
                if($list[$key]['lang']=="ADMIN_TAG_INDEX"){
                    $i=$key;
                }
            }
        unset($list[$i]);
        }
//        return  print_r($i);
        
        $this->assign("SUBMENU_CONFIG", $list);
		$admin_id = $_SESSION['ADMIN_ID'];
		//判断 管理员是否有权限 查看下载页
		$role_down = 1;
		if($admin_id != 1 || !$admin_id) {
			$role_str = "'快直播-高级管理员','快直播-录播管理员','快直播-直播管理员','快直播-直播推流管理员','快直播-图文直播管理员'";
			$role_ids = RoleModel::role_id_get($role_str,$admin_id);
			if($role_ids != 1){
				$role_down = 2;
			}
		}

		$this->assign("role_down",$role_down);
       	$this->display();
        
    }
    
    private function load_menu_lang(){
    	$apps=sp_scan_dir(SPAPP."*",GLOB_ONLYDIR);
    	$error_menus=array();
    	foreach ($apps as $app){
    		if(is_dir(SPAPP.$app)){
    			$admin_menu_lang_file=SPAPP.$app."/Lang/".LANG_SET."/admin_menu.php";
    			if(is_file($admin_menu_lang_file)){
    				$lang=include $admin_menu_lang_file;
    				L($lang);
    			}
    		}
    	}
    }

}

